#include "timer.hpp"

Timer::Timer(UINT32 max_msecs): _original_time(boost::posix_time::second_clock::local_time()),_max_msecs(max_msecs)
{

}

bool Timer::is_time_up()
{
	boost::posix_time::ptime now(boost::posix_time::second_clock::local_time());
	boost::posix_time::time_duration diff = now-_original_time;
	UINT32 differance=(UINT32)diff.total_milliseconds();
	if(differance>_max_msecs)
	{
		return true;
	}
	return false;
}

UINT32 Timer::fraction_of_time_passed()
{
	boost::posix_time::ptime now(boost::posix_time::second_clock::local_time());
	boost::posix_time::time_duration diff = now-_original_time;
	UINT32 differance=(UINT32)diff.total_milliseconds();
	return _max_msecs/differance;
}